package mi.payment.ui.other;

import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import lainey.ui.widget.TitleView;
import mi.payment.R;
import mi.payment.transaction.ParamsCheckExt;
import mi.payment.transaction.sale.ICCardInputMoneyActivity;
import mi.payment.ui.base.ParentActivity;

/**
 * 其他界面
 */
public class OtherActivity extends ParentActivity {

    private ParamsCheckExt mParamsCheckExt;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.other_activity_main);
        initView();
    }

    private void initView() {
        mParamsCheckExt = new ParamsCheckExt(this);
        mParamsCheckExt.setOnLogonStateListener(
                new ParamsCheckExt.LogonStateListener() {

                    @Override
                    public void onLogonSuccess() {
                        ICCardInputMoneyActivity.startAction(mActivity);
                        finish();
                    }

                    @Override
                    public void onLogonFailed() {

                    }

                }
        );

        TitleView titleView = findViewById(R.id.title_view);
        titleView.setCenterText(R.string.other);
        titleView.setLeftImageOnClickListener(
                v -> onBackPressed()
        );

        View item = findViewById(R.id.item_ic);
        item.findViewById(R.id.left_image).setVisibility(View.GONE);
        TextView leftText = item.findViewById(R.id.left_text);
        item.findViewById(R.id.right_text).setVisibility(View.GONE);
        leftText.setText(R.string.other_force_ic);
        item.setOnClickListener(this);

        item = findViewById(R.id.item_language);
        item.findViewById(R.id.left_image).setVisibility(View.GONE);
        leftText = item.findViewById(R.id.left_text);
        item.findViewById(R.id.right_text).setVisibility(View.GONE);
        leftText.setText(R.string.other_language);
        item.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        final int id = v.getId();
        switch (id) {
            case R.id.item_ic:
                boolean isCheck = mParamsCheckExt.check(true, true, true, true);
                if (isCheck) return;

                ICCardInputMoneyActivity.startAction(this);
                finish();
                break;
            case R.id.item_language:
                openActivity(LanguageActivity.class);
                break;
            default:
                break;
        }
    }


}
